import requests
import asyncio
import time


class myAsync():
    def __init__(self, my_func, my_list):
        self.my_func = my_func
        self.my_list = my_list

    async def main(self):
        tasks = []
        for target in self.my_list:
            tasks.append(asyncio.ensure_future(self.my_func(target)))
        for future in asyncio.as_completed(tasks):
            pass
            # result =await future
            # print(result)

    def start(self):
        loop = asyncio.get_event_loop()
        loop.run_until_complete(self.main())


async def test_func(test):
    requests.get("http://www.qq.com")
    # await something
    print('get [url]http://t00ls.net/[/url]{}'.format(test))
    # return test


if __name__ == '__main__':
    test_list = range(1, 9)
    myAsync = myAsync(test_func, test_list)  # init
    last_time = time.time()
    myAsync.start()
    print('time is {}'.format(time.time() - last_time))
